/* ** por compatibilidad se omiten tildes **
================================================================================
 TRABAJO PRACTICO 3 - System Programming - ORGANIZACION DE COMPUTADOR II - FCEN
================================================================================
  definicion de la tabla de descriptores globales
*/
#include "defines.h"

#include "gdt.h"
#include "tss.h"

gdt_entry gdt[GDT_COUNT] = {

	/* Descriptor nulo  indice 0*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo  indice 1*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 2*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 3*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 4*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 5*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 6*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 7*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 8*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },
	/* Descriptor nulo indice 9*/
	(gdt_entry){(unsigned int) 0x00000000, (unsigned int) 0x00000000 },

	/*Descriptor indice 10 codigo nivel 0*/
	(gdt_entry){
		(unsigned short) 0xFFFF,// limit_0_15
		(unsigned short) 0x0000,// base_0_15
		(unsigned char) 0x00, 	// base_23_16
		(unsigned char) 0x9, 	// type
		(unsigned char) 0x1, 	// s
		(unsigned char) 0x0, 	// dpl
		(unsigned char) 0x1, 	// p
		(unsigned char) 0xF, 	// limit_16_19
		(unsigned char) 0x0, 	// avl
		(unsigned char) 0x0, 	// l
		(unsigned char) 0x1, 	// db
		(unsigned char) 0x1, 	// g
		(unsigned char) 0x0  	// base_31_24
	},

	/*Descriptor indice 11 datos nivel 0*/
	(gdt_entry){
		(unsigned short) 0xFFFF,// limit_0_15
		(unsigned short) 0x0000,// base_0_15
		(unsigned char) 0x00, 	// base_23_16
		(unsigned char) 0x2, 	// type
		(unsigned char) 0x1, 	// s
		(unsigned char) 0x0, 	// dpl
		(unsigned char) 0x1, 	// p
		(unsigned char) 0xF, 	// limit_16_19
		(unsigned char) 0x0, 	// avl
		(unsigned char) 0x0, 	// l
		(unsigned char) 0x1, 	// db
		(unsigned char) 0x1, 	// g
		(unsigned char) 0x0  	// base_31_24
	},

	/*Descriptor indice 12 codigo nivel 3*/
	(gdt_entry){
		(unsigned short) 0xFFFF,// limit_0_15
		(unsigned short) 0x0000,// base_0_15
		(unsigned char) 0x00, 	// base_23_16
		(unsigned char) 0xA, 	// type
		(unsigned char) 0x1, 	// s
		(unsigned char) 0x3, 	// dpl
		(unsigned char) 0x1, 	// p
		(unsigned char) 0xF, 	// limit_16_19
		(unsigned char) 0x0, 	// avl
		(unsigned char) 0x0, 	// l
		(unsigned char) 0x1, 	// db
		(unsigned char) 0x1, 	// g
		(unsigned char) 0x0  	// base_31_24
	},

	/*Descriptor indice 13 datos nivel 3*/
	(gdt_entry){
		(unsigned short) 0xFFFF,// limit_0_15
		(unsigned short) 0x0000,// base_0_15
		(unsigned char) 0x00, 	// base_23_16
		(unsigned char) 0x2, 	// type
		(unsigned char) 0x1, 	// s
		(unsigned char) 0x0, 	// dpl
		(unsigned char) 0x1, 	// p
		(unsigned char) 0xF, 	// limit_16_19
		(unsigned char) 0x0, 	// avl
		(unsigned char) 0x0, 	// l
		(unsigned char) 0x1, 	// db
		(unsigned char) 0x1, 	// g
		(unsigned char) 0x0  	// base_31_24
	},

	/*Descriptor indice 14 video*/
	(gdt_entry){
		(unsigned short) 0x0F9F,// limit_0_15 ---- limite = 80*25*2 = 4000 = 0xFA0
		(unsigned short) 0x8000,// base_0_15
		(unsigned char) 0x0B, 	// base_23_16
		(unsigned char) 0x2, 	// type
		(unsigned char) 0x1, 	// s
		(unsigned char) 0x0, 	// dpl
		(unsigned char) 0x1, 	// p
		(unsigned char) 0x0, 	// limit_16_19
		(unsigned char) 0x0, 	// avl
		(unsigned char) 0x0, 	// l
		(unsigned char) 0x1, 	// db
		(unsigned char) 0x0, 	// g
		(unsigned char) 0x0  	// base_31_24
	}
};

gdt_descriptor GDT_DESC = {sizeof(gdt)-1, (unsigned int)&gdt};
